<template>
  <v-app ref="app">
    <v-main>
      <router-view />
    </v-main>
  </v-app>

  <v-snackbar v-model="vMsg.show" location="top">
    {{ vMsg.msg }}
  </v-snackbar>
</template>

<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { uMsg } from "./store/vMessage";
import { useIndexDB } from "./store/indexedDB";
import { useConfig } from "./store/localConfig";
import { useSocketInfoStore } from "./store/webSocket";

const vMsg = uMsg();
const app = ref();

const DB = useIndexDB();
const websocket = useSocketInfoStore();
const config = useConfig();

onMounted(() => {
  // 初始化连接数据库
  DB.initDB();

  // 刷新重连
  if (websocket.isConnent) {
    websocket.initWS();
  }

  config.screenWidth = app.value.$el.offsetWidth;
});
</script>
